//
//  Filters.swift
//  Automobile
//
//  Created by erkebulan elzhan on 7/22/20.
//  Copyright © 2020 erkebulan elzhan. All rights reserved.
//

import Foundation


struct Distance {
    var placeholder: String
    var value: Int
}

enum TransportFeature: String, CaseIterable {
    case all = "Все"
    case new = "Новые"
    case withProbeg = "С пробегом"
}

enum PersonType: String, CaseIterable {
    case all = "Все"
    case company = "Компания"
    case owner = "Частник"
}


struct InputView {
    var parameters: [ParametersViewModel]
}
struct Segmented {
    var segments: [String]
}

struct CarFilter {
    var marka: Marka?
    var models: [Model]
    var series: [Serie]?
    var modififcations: [Modification]?
    var color: CarColor?=nil
    var probeg: Int?
}

struct Filter {
    struct FilterGeneral {
        var region: [City]?
        var transportFeature: String?
        //var carType: TransportType?
    }
    
    struct FilterCar {
        var carParameters: CarFilter?
    }
    
    struct FilterOptional {
        
        var priceFrom: Int?
        var priceTo: Int?
        
        var yearFrom: Int?
        var yearTo: Int?
        
        var powerFrom: Int?
        var powerTo: Int?
        
        var probegFrom: Int?
        var probegTo: Int?
        
        var volumeFrom: Double?
        var volumeTo: Double?
        
        var expenditureFrom: Int?
        var expenditureTo: Int?
        
        var korobka: [ModalView.ModalData]?
        var kuzov: [ModalView.ModalData]?
        var dvigatel: [ModalView.ModalData]?
        var colors: [ModalView.ModalData]?
        var privods: [ModalView.ModalData]?
        var rule: [ModalView.ModalData]?
        
        
        var options_single_fields: String? = ""
        var options_choice_fields: String? = ""
        var options_multiple_fields: String? = ""
        
        
        subscript (key: ModalView.ModalType) -> Any?     {
            get {
                switch key {
                    case .color:
                        return colors as Any
                    case .privod:
                        return privods as Any
                    case .korobka:
                        return korobka as Any
                    case .dvigatel:
                        return dvigatel as Any
                    case .kuzov:
                        return kuzov as Any
                    default:
                        return nil
                }
            }
        }
    }
    
    struct FilterChecks {
        
        var personType: PersonType = .all
        var carState: [ModalView.ModalData]?
        
        var firstPurchaseFrom: Int?
        var firstPurchaseTo: Int?
        
        var monthPurchaseFrom: Int?
        var monthPurchaseTo: Int?
        
        var rastomozhenInKZ: Bool = false
        var isGuarantee: Bool = false
        var isObmen: Bool = false
        var onlyPhoto: Bool = false
        var isCredit: Bool = false
        var noFee: Bool = false
        
        
        enum keys: String, CaseIterable {
            case rastomozhenInKZ = "Растоможен в Казахстане"
            case isGuarantee = "На гарантии"
            case isObmen = "Возможен обмен"
            case onlyPhoto = "С фото"
            case isCredit = "Доступны в кредит"
            case noFee = "Без взноса"
        }
        subscript(key: String) -> Bool? {
            get {
                switch key {
                    case "Растоможен в Казахстане": return self.rastomozhenInKZ
                    case "На гарантии": return self.isGuarantee
                    case "Возможен обмен": return self.isObmen
                    case "Только с фото": return self.onlyPhoto
                    case "Без взноса": return self.noFee
                    case "Доступны в кредит": return self.isCredit
                default:
                    return nil
                }
            }
        }
    }
    
    var filterGeneral: FilterGeneral
    var filterCar: FilterCar
    var filterOptional: FilterOptional
    var filterChecks: FilterChecks
    var carDetailedType: CarItem?
    
    var sortBy = 1
    var mode: MarkaModelMode = .include
}




